home *** CD-ROM | disk | FTP | other *** search
/ Clickx 115 / Clickx 115.iso / software / tools / windows / tails-i386-0.16.iso / live / filesystem.squashfs / usr / include / scribus-ng / undomanager.h < prev    next >
Encoding:
C/C++ Source or Header  |  2009-04-16  |  25.1 KB  |  787 lines

  1. /*
  2. For general Scribus (>=1.3.2) copyright and licensing information please refer
  3. to the COPYING file provided with the program. Following this notice may exist
  4. a copyright and/or license notice that predates the release of Scribus 1.3.2
  5. for which a new license (GPL+exception) is in place.
  6. */
  7. /***************************************************************************
  8.  *   Copyright (C) 2005 by Riku Leino                                      *
  9.  *   riku@scribus.info                                                     *
  10.  *                                                                         *
  11.  *   This program is free software; you can redistribute it and/or modify  *
  12.  *   it under the terms of the GNU General Public License as published by  *
  13.  *   the Free Software Foundation; either version 2 of the License, or     *
  14.  *   (at your option) any later version.                                   *
  15.  *                                                                         *
  16.  *   This program is distributed in the hope that it will be useful,       *
  17.  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
  18.  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
  19.  *   GNU General Public License for more details.                          *
  20.  *                                                                         *
  21.  *   You should have received a copy of the GNU General Public License     *
  22.  *   along with this program; if not, write to the                         *
  23.  *   Free Software Foundation, Inc.,                                       *
  24.  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
  25.  ***************************************************************************/
  26.  
  27. #ifndef UNDOMANAGER_H
  28. #define UNDOMANAGER_H
  29.  
  30. #include <vector>
  31. #include <utility>
  32. #include <QObject>
  33. #include <QPixmap>
  34.  
  35. #include "scribusapi.h"
  36. #include "transaction.h"
  37. #include "undostate.h"
  38. #include "undoobject.h"
  39. #include "undostack.h"
  40.  
  41. class QString;
  42. class QPixmap;
  43. class UndoGui;
  44. class PrefsContext;
  45.  
  46. struct TransactionData;
  47.  
  48. /** @brief Key is the doc name, value is it's undo stack */
  49. typedef QMap<QString, UndoStack> StackMap;
  50.  
  51. class SCRIBUS_API TransactionSettings
  52. {
  53. public:
  54.     QString  targetName;
  55.     QPixmap *targetPixmap;
  56.     QString  actionName;
  57.     QString  description;
  58.     QPixmap *actionPixmap;
  59.  
  60.     TransactionSettings(void) { targetPixmap = actionPixmap = NULL; }  
  61. };
  62.  
  63. /**
  64.  * @brief TransactionState provides a container where multiple UndoStates can be stored
  65.  * @brief as a single action which then appears in the attached <code>UndoGui</code>s.
  66.  * @author Riku Leino riku@scribus.info
  67.  * @date January 2005
  68.  */
  69. class TransactionState : public UndoState
  70. {
  71. public:
  72.     /** @brief Creates a new TransactionState instance */
  73.     TransactionState();
  74.     /** @brief Destroys the TransactionState instance */
  75.     ~TransactionState();
  76.     
  77.     /**
  78.      * @brief Add a new <code>UndoState</code> object to the transaction.
  79.      * @param state state to be added to the transaction
  80.      */
  81.     void pushBack(UndoObject *target, UndoState *state);
  82.     /**
  83.      * @brief Returns the count of the <code>UndoState</code> objects in this transaction.
  84.      * @return count of the <code>UndoState</code> objects in this transaction
  85.      */
  86.     uint sizet();
  87.     /** @brief Use the name from last action added to this <code>TransactionState</code> */
  88.     void useActionName();
  89.     /**
  90.      * @brief Returns an <code>UndoState</code> object at <code>index</code>.
  91.      * @param index index from where an <code>UndoState</code> object is returned.
  92.      * If <code>index</code> is out of scope <code>NULL</code> will be rerturned.
  93.      * @return <code>UndoState</code> object from <code>index</code> or <code>NULL</code>
  94.      * if <code>index</code> is out of scope.
  95.      */
  96.     UndoState* at(int index);
  97.     /**
  98.      * @brief Returns true if this transaction contains UndoObject with the id <code>uid</code>
  99.      * @brief otherwise returns false.
  100.      * @return true if this transaction contains UndoObject with the ide <code>uid</code>
  101.      * @return otherwise returns false.
  102.      */
  103.     bool contains(int uid) const;
  104.     
  105.     /**
  106.      * @brief Tells if this transaction contains only UndoObject with ID uid
  107.      * 
  108.      * If a transaction contains only single UndoObject it will be safe to include
  109.      * it in the object specific undo.
  110.      * @param uid UndoObject's id to look for
  111.      * @return true if this transaction only contains actions of the UndoObject whose
  112.      *         id is uid
  113.      */
  114.     bool containsOnly(int uid) const;
  115.     /**
  116.      * @brief Replace object with id uid with new UndoObject newUndoObject.
  117.      * @param uid id of the object that is wanted to be replaced
  118.      * @param newUndoObject object that is used for replacing
  119.      * @return UndoObject which was replaced
  120.      */
  121.     UndoObject* replace(ulong uid, UndoObject *newUndoObject);
  122.  
  123.     /** @brief undo all UndoStates in this transaction */
  124.     void undo();
  125.     /** @brief redo all UndoStates in this transaction */
  126.     void redo();
  127. private:
  128.     /** @brief Number of undo states stored in this transaction */
  129.     uint size_;
  130.     /** @brief vector to keep the states in */
  131.     std::vector<UndoState*> states_;
  132. };
  133.  
  134.  
  135.  
  136. /**
  137.     Class which handles Undo transactions. No data, just methods.
  138.  */
  139. class UndoTransaction : public Transaction
  140. {
  141. public:
  142.     UndoTransaction(TransactionData* data);
  143.     virtual ~UndoTransaction();
  144.     virtual bool commit();
  145.     virtual bool cancel();
  146.     bool commit(const QString &targetName,
  147.                 QPixmap *targetPixmap,
  148.                 const QString &name = "",
  149.                 const QString &description = "",
  150.                 QPixmap *actionPixmap = 0);
  151. };
  152.  
  153.  
  154. /**
  155.  * @brief UndoManager handles the undo stack.
  156.  *
  157.  * UndoManager is the engine of the undo/redo handling. When ever an undoable
  158.  * action happens an UndoState object will be sent to the UndoManager which then
  159.  * stores the state in the undo stack. When an undo is requested the state is
  160.  * send back to it's creator which is then responsible for doing the actual undo or
  161.  * redo.
  162.  *
  163.  * UndoManager also handles the UndoGuis by linking them together and reporting
  164.  * all undo/redo actions to the guis for them to update the visual representation.
  165.  * For this to work all UndoGuis need to be registered to the UndoManager with the
  166.  * registerGui() method.
  167.  *
  168.  * @author Riku Leino tsoots@gmail.com
  169.  * @date December 2004
  170.  */
  171. class SCRIBUS_API UndoManager : public QObject
  172. {
  173.     Q_OBJECT
  174. public:
  175.     friend class UndoTransaction;
  176.     
  177.     /** @brief Marks for a global undo mode where ever UndoOjbect id is requested. */
  178.     static const int GLOBAL_UNDO_MODE = -1;
  179.     
  180.     /**
  181.      * @brief When object specific mode is requested but no suitable object is selected
  182.      * @brief this can be passed to showObject() to clear the undo stack representations.
  183.      */
  184.     static const int NO_UNDO_STACK = -2;
  185.     
  186.     /**
  187.      * @brief Returns a pointer to the UndoManager instance
  188.      * @return A pointer to the UndoManager instance
  189.      */
  190.     static UndoManager* instance();
  191.     
  192.     /**
  193.      * @brief Deletes the UndoManager Instance
  194.      *
  195.      * Must be called when UndoManager is no more needed.
  196.      */
  197.     static void deleteInstance();
  198.     
  199.     /**
  200.      * @brief Sets the undo action tracking enabled or disabled.
  201.      * @param isEnabled If true undo stack is updated with the states sent
  202.      * to the UndoManager else undo stack is not updated and attached UndoGuis
  203.      * are not informed of the actions.
  204.      */
  205.     void setUndoEnabled(bool isEnabled);
  206.     
  207.     /**
  208.      * @brief Returns true if undo actions are stored, if not will return false.
  209.      * @return true if undo actions are stored, if not will return false
  210.      */
  211.     static bool undoEnabled();
  212.     
  213.     /**
  214.      * @brief Start a transaction.
  215.      *
  216.      * After this method has been invoked <code>UndoManager</code> will switch to the
  217.      * transaction (silent) mode where it does not report actions to the attached
  218.      * <code>UndoGui</code> widgets but stores all incoming <code>UndoState</code> objects into
  219.      * the transaction container which after call to the method commit() will be sent
  220.      * to the guis as a single undo action. Transaction can be named when starting it or
  221.      * naming can be done when commiting it.
  222.      * @param targetName name for the target of this transaction (f.e. "Selection")
  223.      * @param targetPixmap Icon for the target on which this transaction works.
  224.      * this icon will be drawn first when the action is presented in Action History
  225.      * window and icon for the action will be drawn over this one.
  226.      * @param actionName name for the transaction (f.e. "Move" would make with the above
  227.      * "Move Selection")
  228.      * The result can only be used for initializing a Transaction object, eg. on the stack:
  229.      *      Transaction groupTransaction(undoManger->beginTransaction(...));
  230.      * or the heap:
  231.      *      Transaction* groupTransactionPtr = new Transaction(undoManger->beginTransaction(...));
  232.      * @param description description for the transaction
  233.      * @param actionPixmap icon for the action performed by the transaction
  234.      * @sa commit()
  235.      */
  236.     UndoTransaction beginTransaction(const QString &targetName = "",
  237.                                      QPixmap *targetPixmap = 0,
  238.                                      const QString &actionName = "",
  239.                                      const QString &description = "",
  240.                                      QPixmap *actionPixmap = 0);
  241.  
  242.     UndoTransaction beginTransaction(const TransactionSettings& settings);
  243.     
  244.     /**
  245.      * @brief Cancels the current transaction and deletes groupped <code>UndoState</code>s.
  246.      * @brief Nothing from canceled transaction will be sent to the undo gui widgets.
  247.      */
  248.     //void cancelTransaction();
  249.     
  250.     /*
  251.      * @brief Commit the current transaction.
  252.      *
  253.      * Current transaction will be commited and <code>UndoManager</code> will be switched
  254.      * to the normal mode. Commited transaction will be sent to the attached undo gui
  255.      * widgets and it will show up there as a single undo action. Details used as a parameter
  256.      * will be details shown in the gui widgets.
  257.      * @param targetName name for the target of this transaction (f.e. "Selection")
  258.      * @param targetPixmap Icon for the target on which this transaction works.
  259.      * this icon will be drawn first when the action is presented in Action History
  260.      * window and icon for the action will be drawn over this one.
  261.      * @param name name for the action
  262.      * @param description description for the action
  263.      * @param actionPixmap icon for the action performed by the transaction
  264.      * @sa beginTransaction()
  265.      */
  266. //    void commit(const QString &targetName = "",
  267. //                QPixmap *targetPixmap = 0,
  268. //                const QString &name = "",
  269. //                const QString &description = "",
  270. //                QPixmap *actionPixmap = 0);
  271.     
  272.     /**
  273.      * @brief Returns true if in transaction mode if not will return false.
  274.      * @return bool true if in transaction mode if not will return false
  275.      */
  276.     bool isTransactionMode();
  277.     
  278.     /**
  279.      * @brief Register an UndoGui to the UndoManager.
  280.      *
  281.      * After registering a gui to the manager the gui will be updated with the
  282.      * undo action information received by the UndoManager. Actions done with the
  283.      * UndoGui to be registered are also handled after registering.
  284.      * @param gui A pointer to the UndoGui that is wanted to be registered.
  285.      */
  286.     void registerGui(UndoGui* gui);
  287.     
  288.     /**
  289.      * @brief Removes an UndoGui from UndoManager.
  290.      * @param gui UndoGui to be removed from the UndoManager.
  291.      */
  292.     void removeGui(UndoGui* gui);
  293.     
  294.     /**
  295.      * @brief Changes the active undo stack.
  296.      *
  297.      * Sets the stack connected to the name <code>stackName</code> active. Calling
  298.      * this method will send clear() signal to the attached <code>UndoGui</code>s and
  299.      * will update their undo stack representations.
  300.      * @param stackName Name of the stack to be used
  301.      */
  302.     void switchStack(const QString& stackName);
  303.     
  304.     /**
  305.      * @brief Rename the current stack
  306.      * @param newName New name for the current stack.
  307.      */
  308.     void renameStack(const QString& newName);
  309.     
  310.     /**
  311.      * @brief Remove the stack with the name <code>stackName</code>
  312.      * @param stackName Name of the stack that is wanted to be removed
  313.      */
  314.     void removeStack(const QString& stackName);
  315.  
  316.     /** clear the current undo stack */
  317.     void clearStack();
  318.  
  319.     /**
  320.      * @brief Returns true if there are actions that can be undone otherwise returns false.
  321.      *
  322.      * This is useful when undo/redo actions are handled with a gui that is not attached to
  323.      * the UndoManager (f.e. menu items) and when those gui items are wanted to set enabled
  324.      * or disabled depending on the status of the undo stack.
  325.      * @return true if there are actions that can be undone otherwise returns false
  326.      */
  327.     bool hasUndoActions(int uid = -1);
  328.     
  329.     /**
  330.      * @brief Returns true if there are actions that can be redone otherwise returns false.
  331.      * @return true if there are actions that can be redone otherwise returns false
  332.      * @sa UndoManager::hasUndoActions()
  333.      */
  334.     bool hasRedoActions(int uid = -1);
  335.     
  336.     /**
  337.      * @brief Replace an UndoObject with the id uid with a new UndoObject new.
  338.      * @param uid Id for the UndoObject that is wanted to be replaced.
  339.      * @param newUndoObject UndoObject which will replace an old UndoObject in the stack.
  340.      * @return UndoObject which was replaced
  341.      */
  342.     UndoObject* replaceObject(ulong uid, UndoObject *newUndoObject);
  343.     
  344.     /**
  345.      * @brief Returns the maximum length of the undostack.
  346.      * @return the maximum length of the undostack
  347.      */
  348.     int getHistoryLength();
  349.  
  350.     /**
  351.      * @brief Returns true if in global mode and false if in object specific mode.
  352.      * @return true if in global mode and false if in object specific mode
  353.      */
  354.     bool isGlobalMode();
  355.  
  356. private:
  357.     /**
  358.      * @brief The only instance of UndoManager available.
  359.      *
  360.      * UndoManager is singleton and the instance can be queried with the method
  361.      * instance().
  362.      */
  363.     static UndoManager* instance_;
  364.  
  365.     /** @brief Should undo states be stored or ignored */
  366.     static bool undoEnabled_;
  367.  
  368.     /**
  369.      * @brief Tracks the state of _undoEnabled.
  370.      *
  371.      * This value is increased whenever setUndoEnabled(true) is called and decreased
  372.      * when setUndoEnabled(false) is called. This means _undoEnabled == true when this
  373.      * value is 0 and when its above zero _undoEnabled == false. Counting setUndoEnabled()
  374.      * calls this way guarantees that undo is not enabled accidentally calling
  375.      * setUndoEnabled(true) even it has been set false before this false-true pair touched it.
  376.      */
  377.     static int undoEnabledCounter_;
  378.  
  379.     PrefsContext *prefs_;
  380.  
  381.     /** @brief Doc to which the currently active stack belongs */
  382.     QString currentDoc_;
  383.  
  384.     /**
  385.      * @brief Id number of the object for what the object specific undo is shown
  386.      * @brief or -1 if global undo is used.
  387.      */
  388.     int currentUndoObjectId_;
  389.  
  390.     /**
  391.      * @brief Stores the transactions which are currently started but not
  392.      * @brief canceled or commited.
  393.      */
  394.     std::vector<TransactionData*> transactions_;
  395.  
  396.     /**
  397.      * @brief UndoGuis attached to this UndoManager
  398.      * @sa UndoGui
  399.      * @sa UndoWidget
  400.      * @sa UndoPalette
  401.      */
  402.     std::vector<UndoGui*> undoGuis_;
  403.  
  404.     /**
  405.      * @brief Undo stacks for all open document
  406.      *
  407.      * Whenever current stack is used it's referred with <code>stacks_[currentDoc_]</code>
  408.      */
  409.     StackMap stacks_;
  410.  
  411.     /**
  412.      * @brief Initializes the UndoGui.
  413.      * @param gui UndoGui to be initialized
  414.      * @param uid UndoObject's id if in object specific mode or -1 to tell
  415.      * that global undo is used.
  416.      */
  417.     void setState(UndoGui* gui, int uid = -1);
  418.  
  419.     /**
  420.      * @brief Disconnect all attached UndoGui instances from signals provided by this
  421.      * @brief class and other UndoGui objects.
  422.      */
  423.     void connectGuis();
  424.     /**
  425.      * @brief Connect all attached UndoGui instances to signals provided by this
  426.      * @brief class and other UndoGui objects.
  427.      */
  428.     void disconnectGuis();
  429.     /**
  430.      * @brief Load icons needed for Action History window.
  431.      */
  432.     void initIcons();
  433.  
  434.     void setTexts();
  435.  
  436. public:
  437.  
  438.     /**
  439.     * @name Action strings
  440.     * Strings describing undo actions
  441.     */
  442.     /*@{*/
  443.     static QString AddVGuide;
  444.     static QString AddHGuide;
  445.     static QString DelVGuide;
  446.     static QString DelHGuide;
  447.     static QString DelVAGuide;
  448.     static QString DelHAGuide;
  449.     static QString MoveVGuide;
  450.     static QString MoveHGuide;
  451.     static QString RemoveAllGuides;
  452.     static QString RemoveAllPageGuides;
  453.     static QString LockGuides;
  454.     static QString UnlockGuides;
  455.     static QString Move;
  456.     static QString Resize;
  457.     static QString Rotate;
  458.     static QString MoveFromTo;
  459.     static QString ResizeFromTo;
  460.     static QString ImageOffset;
  461.     static QString ImageScale;
  462.     static QString ImageOffsetFromTo;
  463.     static QString ImageScaleFromTo;
  464.     static QString Selection;
  465.     static QString Group;
  466.     static QString SelectionGroup;
  467.     static QString Create;
  468.     static QString CreateTo;
  469.     static QString AlignDistribute;
  470.     static QString ItemsInvolved;
  471.     static QString ItemsInvolved2;
  472.     static uint    ItemsInvolvedLimit;
  473.     static QString Cancel;
  474.     static QString SetFill;
  475.     static QString ColorFromTo;
  476.     static QString SetShade;
  477.     static QString SetLineColor;
  478.     static QString SetLineShade;
  479.     static QString FlipH;
  480.     static QString FlipV;
  481.     static QString Lock;
  482.     static QString UnLock;
  483.     static QString SizeLock;
  484.     static QString SizeUnLock;
  485.     static QString EnablePrint;
  486.     static QString DisablePrint;
  487.     static QString Ungroup;
  488.     static QString Delete;
  489.     static QString Rename;
  490.     static QString FromTo;
  491.     static QString ApplyMasterPage;
  492.     static QString Paste;
  493.     static QString Cut;
  494.     static QString Transparency;
  495.     static QString LineTransparency;
  496.     static QString LineStyle;
  497.     static QString LineEnd;
  498.     static QString LineJoin;
  499.     static QString LineWidth;
  500.     static QString NoStyle;
  501.     static QString CustomLineStyle;
  502.     static QString NoLineStyle;
  503.     static QString StartArrow;
  504.     static QString EndArrow;
  505.     static QString StartAndEndArrow;
  506.     static QString CreateTable;
  507.     static QString RowsCols;
  508.     static QString SetFont;
  509.     static QString SetFontSize;
  510.     static QString SetFontWidth;
  511.     static QString SetFontHeight;
  512.     static QString SetFontFill;
  513.     static QString SetFontStroke;
  514.     static QString SetFontFillShade;
  515.     static QString SetFontStrokeShade;
  516.     static QString SetKerning;
  517.     static QString SetLineSpacing;
  518.     static QString SetStyle;
  519.     static QString SetLanguage;
  520.     static QString AlignText;
  521.     static QString SetFontEffect;
  522.     static QString ImageFrame;
  523.     static QString TextFrame;
  524.     static QString LatexFrame;
  525.     static QString Polygon;
  526.     static QString BezierCurve;
  527.     static QString Polyline;
  528.     static QString PathText;
  529.     static QString ConvertTo;
  530.     static QString ImportSVG;
  531.     static QString ImportEPS;
  532.     static QString ImportBarcode;
  533.     static QString ImportOOoDraw;
  534.     static QString ImportAI;
  535.     static QString ImportXfig;
  536.     static QString ImportWMF;
  537.     static QString ScratchSpace;
  538.     //static QString TextFlow;
  539.     static QString ObjectFrame;
  540.     static QString BoundingBox;
  541.     static QString ContourLine;
  542.     static QString ImageClip;
  543.     static QString NoTextFlow;
  544.     static QString NoObjectFrame;
  545.     static QString NoBoundingBox;
  546.     static QString NoContourLine;
  547.     static QString PageNmbr;
  548.     static QString ImageScaling;
  549.     static QString FrameSize;
  550.     static QString FreeScaling;
  551.     static QString KeepRatio;
  552.     static QString BreakRatio;
  553.     static QString EditContourLine;
  554.     static QString EditShape;
  555.     static QString ChangeShapeType;
  556.     static QString ResetContourLine;
  557.     static QString AddPage;
  558.     static QString AddPages;
  559.     static QString DeletePage;
  560.     static QString DeletePages;
  561.     static QString AddLayer;
  562.     static QString DuplicateLayer;
  563.     static QString DeleteLayer;
  564.     static QString RenameLayer;
  565.     static QString RaiseLayer;
  566.     static QString LowerLayer;
  567.     static QString SendToLayer;
  568.     static QString PrintLayer;
  569.     static QString DoNotPrintLayer;
  570.     static QString SetLayerName;
  571.     static QString GetImage;
  572.     static QString ChangeFormula;
  573.     static QString MultipleDuplicate;
  574.     static QString ApplyTextStyle;
  575.     static QString MenuUndo;
  576.     static QString MenuUndoEmpty;
  577.     static QString MenuRedo;
  578.     static QString MenuRedoEmpty;
  579.     static QString EditContour;
  580.     static QString ResetControlPoint;
  581.     static QString ResetControlPoints;
  582.     static QString ImageEffects;
  583.     static QString InsertFrame;
  584.     static QString AdjustFrameToImage;
  585.     static QString Copy;
  586.     static QString CopyPage;
  587.     static QString ToOutlines;
  588.     /*@}*/
  589.  
  590.     /**
  591.      * @name Action icons
  592.      * Icons for undo actions
  593.      */
  594.     /*@{*/
  595. /*** Icons for UndoObjects *******************************************/
  596.     static QPixmap *IImageFrame;
  597.     static QPixmap *ITextFrame;
  598.     static QPixmap *ILatexFrame;
  599.     static QPixmap *ILine;
  600.     static QPixmap *IPolygon;
  601.     static QPixmap *IPolyline;
  602.     static QPixmap *IPathText;
  603.     static QPixmap *IGroup;
  604.     static QPixmap *ILayer;
  605. /*** Icons for actions ***********************************************/
  606.     static QPixmap *IMove;
  607.     static QPixmap *IResize;
  608.     static QPixmap *IRotate;
  609.     static QPixmap *IGuides;
  610.     static QPixmap *ILockGuides;
  611.     static QPixmap *IAlignDistribute;
  612.     static QPixmap *IFill;
  613.     static QPixmap *IShade;
  614.     static QPixmap *IFlipH;
  615.     static QPixmap *IFlipV;
  616.     static QPixmap *ILock;
  617.     static QPixmap *IUnLock;
  618.     static QPixmap *IEnablePrint;
  619.     static QPixmap *IDisablePrint;
  620.     static QPixmap *IDelete;
  621.     static QPixmap *ICreate;
  622.     static QPixmap *IPaste;
  623.     static QPixmap *ICut;
  624.     static QPixmap *ITransparency;
  625.     static QPixmap *ILineStyle;
  626.     static QPixmap *IArrow;
  627.     static QPixmap *ITable;
  628.     static QPixmap *IFont;
  629.     static QPixmap *ISVG;
  630.     static QPixmap *IEPS;
  631.     static QPixmap *IAI;
  632.     static QPixmap *IXFIG;
  633.     static QPixmap *IWMF;
  634.     static QPixmap *IImportOOoDraw;
  635.     static QPixmap *IImageScaling;
  636.     static QPixmap *IBorder;
  637.     static QPixmap *IDocument;
  638.     static QPixmap *ILayerAction;
  639.     static QPixmap *IUp;
  640.     static QPixmap *IDown;
  641.     static QPixmap *IPrint;
  642.     static QPixmap *IGetImage;
  643.     static QPixmap *IChangeFormula;
  644.     static QPixmap *IMultipleDuplicate;
  645.     /*@}*/
  646.  
  647. protected:
  648.     /** @brief Creates a new UndoManager instance */
  649.     UndoManager();
  650.  
  651.     /** @brief Destroys the UndoManager instance */
  652.     ~UndoManager();
  653.  
  654. public slots:
  655.     /**
  656.      * @brief Updates strings when the GUI language is changed.
  657.      */
  658.     void languageChange();
  659.     
  660.     /**
  661.      * @brief Adds a new action to the undo stack.
  662.      *
  663.      * If _unodEnabled is true the action will be stored otherwise it will
  664.      * be just ignored. When a new action is added redo items from the stack
  665.      * will be removed and the current action will be set to the one which was
  666.      * added.
  667.      * @param target Source of the action. When undoing/redoing this action
  668.      * restore() method of this UndoObject will be called.
  669.      * @param state UndoSate describing the state (action).
  670.      * @param targetPixmap Is used to override the default target icon in this action.
  671.      */
  672.     void action(UndoObject* target, UndoState* state, QPixmap *targetPixmap = 0);
  673.  
  674.     /**
  675.      * @brief Adds a new action to the undo stack.
  676.      *
  677.      * If _unodEnabled is true the action will be stored otherwise it will
  678.      * be just ignored. When a new action is added redo items from the stack
  679.      * will be removed and the current action will be set to the one which was
  680.      * added.
  681.      * @param target Source of the action. When undoing/redoing this action
  682.      * restore() method of this UndoObject will be called.
  683.      * @param state UndoSate describing the state (action).
  684.      * @param targetName Is used to override the default target name in this action.
  685.      * @param targetPixmap Is used to override the default target icon in this action.
  686.      */
  687.     void action(UndoObject* target, UndoState* state, const QString &targetName, QPixmap *targetPixmap = 0);
  688.  
  689.     /**
  690.      * @brief Informs UndoManager to perform undo
  691.      *
  692.      * If an undo is wanted and the caller is not registered UndoGui this method
  693.      * can be used. Useful for example with the menu entry for undo.
  694.      * @param steps Number of undo steps to take
  695.      */
  696.     void undo(int steps);
  697.  
  698.     /**
  699.      * @brief Informs UndoManager to perform redo
  700.      * @param steps Number of redo steps to take
  701.      * @sa UndoManager::undo(int steps)
  702.      */
  703.     void redo(int steps);
  704.  
  705.     /**
  706.      * @brief Switches the state of UndoManager (global/object specific undo).
  707.      *
  708.      * If parameter uid is less than 0 global undo is used else the undo state
  709.      * is object specific using the object whose uid is given as a parameter.
  710.      * @param uid UndoObject's id for what the object specific undo is wanted or
  711.      * -1 if global undo is wanted.
  712.      */
  713.     void showObject(int uid);
  714.  
  715.     /**
  716.      * @brief Sets the length of the undo stack.
  717.      *
  718.      * Tells how many UndoStates are stored.
  719.      * @param steps number of UndoStates to store in the undo stack
  720.      */
  721.     void setHistoryLength(int steps);
  722.     void setAllHistoryLengths(int steps);
  723.  
  724. signals:
  725.     /**
  726.      * @brief Emitted when a new undo action is stored to the undo stack.
  727.      *
  728.      * This signal is connected to the registered UndoGuis for them to update the
  729.      * visual representation of the undo stack.
  730.      * @param target Source of the action
  731.      * @param state UndoState describing the action
  732.      */
  733.     void newAction(UndoObject* target, UndoState* state);
  734.  
  735.     /**
  736.      * @brief Emitted when an undo action has been done.
  737.      *
  738.      * It is connected to attached guis to inform them to update the visual
  739.      * representation of the undo stack. This signal will be also sent to the
  740.      * <code>UndoGui</code> where it came from.
  741.      * @param steps Number of steps to take
  742.      */
  743.     void undoSignal(int steps);
  744.  
  745.     /**
  746.      * @brief Emitted when a redo action has been done.
  747.      * @param steps Number of steps to take
  748.      * @sa UndoManager::undoSignal(int steps)
  749.      */
  750.     void redoSignal(int steps);
  751.  
  752.     /**
  753.      * @brief Emitted when a new actions comes in and UndoManager is in object
  754.      * @brief specific mode and action does not belong to the currently selected
  755.      * @brief object.
  756.       */
  757.     void clearRedo();
  758.  
  759.     /**
  760.      * @brief This signal is used to notify registered UndoGui instances that
  761.      * @brief history limit is reached and the last item from the stack
  762.      * @brief representation should be removed.
  763.      */
  764.     void popBack();
  765.  
  766.     /**
  767.      * @brief This signal is emitted when beginning a series of undo/redo actions
  768.      *
  769.      * It could be used in the application as a signal to disable temporarily gui
  770.      * updates.
  771.      */
  772.     void undoRedoBegin();
  773.  
  774.     /**
  775.      * @brief This signal is emitted when all requested undo/redo actions have been done.
  776.      *
  777.      * It could be used in the application as a signal when the view can be rendered
  778.      * again after undo/redo.
  779.      */
  780.     void undoRedoDone();
  781.  
  782. };
  783.  
  784. typedef UndoManager Um;
  785.  
  786. #endif
  787.